#include <iostream>
#include <fstream>
using namespace std;

//#define READ_FILE

struct Color
{
	short r, g, b;
	int calcDist2(const Color& c)
	{
		int dist2 = (r-c.r) * (r-c.r) +
					(g-c.g) * (g-c.g) +
					(b-c.b) * (b-c.b);
		return dist2;
	}
};
istream& operator>>(istream& in, Color& c)
{
	in >> c.r >> c.g >> c.b;
	return in;
}
ostream& operator<<(ostream& out, Color& c)
{
	out << '(' << c.r << ',' << c.g << ',' << c.b << ')';
	return out;
}

Color g_color[16];

int findColor(const Color& ori)
{
	int minDist = 0x7fffffff;
	int minIndex = 0;
	for (int i = 0; i < 16; ++i)
	{
		int dist = g_color[i].calcDist2(ori);
		if (dist < minDist)
		{
			minDist = dist;
			minIndex = i;
		}
	}
	return minIndex;
}

int main()
{
#ifdef READ_FILE
	ifstream readIn("1067.input");
	if (!readIn)
	{
		readIn.open("../1067.input");
	}
#else
	#define readIn cin
#endif

	for (int i = 0; i < 16; ++i)
	{
		readIn >> g_color[i];
	}
	
	Color c;
	readIn >> c;
	while (c.r != -1)
	{		
		int i = findColor(c);
		cout << c << " maps to " << g_color[i] << endl;
		readIn >> c;
	}
	
	return 0;
}
